const util = require("../../utils/utils");

let a = getApp();

let list = [
  {
    index: 0,
    Type: 1,
    selPic: "images/index-s.png",
    iconPic: "images/index.png",
    text: "首页",
    path: "/pages/index/index"
  },{
    index:1,
    Type: 1,
    selPic: "images/list-s.png",
    iconPic: "images/list.png",
    text: "练习答题",
    path: "/pages/answer/index?showtabbar=0&type=1"//&type=1
    // text: "排行榜",
    // path: "/pages/paiming/paiming?showtabbar=0"
  },{
    index:2,
    Type: 1,
    selPic: "images/medal-s.png",
    iconPic: "images/medal.png",
    text: "比赛介绍",
    path: "/pages/rule/rule?showtabbar=0"
    //text: "勋章墙",
    //path: "/pages/xuzhang/xuzhang?showtabbar=0"
  },{
    index:3,
    Type: 1,
    selPic: "images/login-s.png",
    iconPic: "images/login.png",
    text: "我的",
    path: "/pages/user/user"
  }

]

Component({
    properties: {
        active: {
            type: Number,
            value: -1
        }
    },
    data: {
        tabbarList: []
    },
    attached: function() {
      this.setData({
        tabbarList: list
      })
    },
    methods: {
        clickTabItem: function(a) {
            var t = a.currentTarget.dataset.index;
            var item = this.data.tabbarList[t];
            if (t === this.data.active){
              console.log("相同下标，不跳转");
              return;
            } 
            wx.reLaunch({
              url: item.path
            });


            // var s = "", r = "newWin";
            // switch (i.Type) {
            //   case "1":
            //     s = "/pages/article/detail/detail?id=" + i.NewsDetailId;
            //     break;

            //   case "2":
            //     s = "/pages/article/list/list", i.NewsCateId && (s += "?id=" + i.NewsCateId + "&from=tab"), 
            //     r = "closeAll";
            //     break;

            //   case "6":
            //     i.AppId ? wx.navigateToMiniProgram({
            //         appId: i.AppId,
            //         fail: function(a) {
            //             util.showToast(JSON.stringify(a) + " (" + i.AppId + ")", {
            //                 Title: "跳转失败"
            //             });
            //         }
            //     }) : e.default.alert("没有配置跳转appid，无法跳转");
            //     break;

            //   case "8":
            //     s = "/pages/index/index", r = "closeAll";
            //     break;

            //   case "9":
            //     s = "/pages/user/user", r = "closeAll";
            //     break;

            //   case "25":
            //     break;

            //   case "27":
            //     s = "/pages/rankingList/rankingList?from=tab", r = "closeAll";
            //     break;

            //   case "90":
            //     s = "/pages/answer/list/list?from=tab", r = "closeAll";
            //     break;

            //   case "91":
            //     s = "/pages/medalList/medalList?from=tab", r = "closeAll";
            //     break;

            //   case "92":
            //     s = "/pages/certificate/certificate?from=tab", r = "closeAll";
            //     break;

            //   case "93":
            //     s = "/pages/activity/activityList/activityList?from=tab", r = "closeAll";
            //     break;

            //   default:
            //     e.default.alert("没有配置对应的跳转，type: " + i.Type);
            // }
            // if (s) switch (r) {
            //   case "newWin":
            //     wx.navigateTo({
            //         url: s
            //     });
            //     break;

            //   case "closeAll":
            //     wx.reLaunch({
            //         url: s
            //     });
            //     break;

            //   case "closeSelf":
            //     wx.redirectTo({
            //         url: s
            //     });
            // }
        }
    }
});